package Exercise;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

/**
 * Description：
 * Author: zhangc
 * Date：2017/8/8 23:25
 */
public class StringCompare {

    public static void main(String[] args) {
        Map map = new HashMap();

        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            String[] words = new String[ n ];
            for (int i = 0; i < n; i++) {
                words[ i ] = scanner.next();
            }
            System.out.println(compareString(words));
        }
    }

    public static String compareString(String[] str) {
        boolean isDic = true;
        boolean isSize = true;
        for (int i = 0; i < str.length - 1; i++) {
            if (str[ i ].compareTo(str[ i + 1 ]) > 0)
                isDic = false;
        }
        for (int i = 0; i < str.length - 1; i++) {
            if (str[ i ].length() > str[ i + 1 ].length())
                isSize = false;
        }
        if (isDic && isSize)
            return "both";
        else if (isDic)
            return "lexicographically";
        else if (isSize)
            return "lengths";
        else return "none";
    }
}
